package com.ty.day1;

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create 2023/11/6 19:14
 */
public class Task2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个整数：");
        int x = sc.nextInt();
        if (isPrime(x)) {//判断是否为素数，是为true，反之false
            int a = x, s = 0;
            while (a > 0) {//对其中每一位进行遍历
                s = s + a % 10;
                a = a / 10;
            }
            for (int i = 0; i < s; i++) {//输出*
                System.out.print("*");
            }
        }else {
            System.out.println(x+"不是素数");
        }

    }

    public static boolean isPrime(int x) {
        for (int i = 2; i < Math.sqrt(x); i++) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }
}
